package com.leeon.container.map;

import java.util.*;

import static net.mindview.util.Print.print;

class Gobol2 {

    private String name;

    public Gobol2(String name) {
        this.name = name;
    }

    public void hot() {
        print(name);
    }

   @Override
    public String toString() {
        return name;
    }

    @Override
    public int hashCode() {
        return super.hashCode();
    }
}


public class Example19 {


    public static void main(String[] args) {

         String[] keys = {"aaaa", "bbb", "ccc", "ddd", "eeee", "ffff", "gggg"};

         Map<String, Gobol2> hashMap = new HashMap<String, Gobol2>();

        for (int i = 0; i < keys.length; i++) {
            hashMap.put(keys[i],new Gobol2(keys[i]));
        }
        print(hashMap);

        HashSet<String> linkedHashSet = new HashSet<>(hashMap.keySet());

        print(linkedHashSet);

        LinkedHashMap<String,Gobol2> linkedHashMap = new LinkedHashMap<String, Gobol2>();

        Iterator<String> it = linkedHashSet.iterator();

        while (it.hasNext()){
            String key = it.next();
            linkedHashMap.put(key,hashMap.get(key));
        }
    }

}
